using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class AppointmentMap : EntityTypeConfiguration<Appointment>
	{
		public AppointmentMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.BookerName)
				.HasMaxLength(50);
				
			this.Property(t => t.Address)
				.HasMaxLength(50);
				
			this.Property(t => t.PhoneNumber)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Appointments");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DoctorScheduleId).HasColumnName("DoctorScheduleId");
			this.Property(t => t.PatientId).HasColumnName("PatientId");
			this.Property(t => t.BookerName).HasColumnName("BookerName");
			this.Property(t => t.Address).HasColumnName("Address");
			this.Property(t => t.PhoneNumber).HasColumnName("PhoneNumber");
			this.Property(t => t.StartTime).HasColumnName("StartTime");
			this.Property(t => t.EndTime).HasColumnName("EndTime");
			this.Property(t => t.Slot).HasColumnName("Slot");
			this.Property(t => t.IsInRange).HasColumnName("IsInRange");
			this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");

			// Relationships
			this.HasOptional(t => t.DoctorSchedule)
				.WithMany(t => t.Appointments)
				.HasForeignKey(d => d.DoctorScheduleId);
				
		}
	}
}

